<template>
	<view>
		<baseHead :showReturn="true" title="沟通过" bg="#fff" color="#000" :right="false"></baseHead>
		<scroll-view scroll-y :style="{'height':windowHeight-customBarH+'px'}"
		@scrolltolower="lower" @refresherrefresh="onrefresh" refresher-enabled='true' refresher-default-style='none' 
		refresher-background='#f1f2f6' refresher-threshold='15' :refresher-triggered='loading'>
		<u-loading-icon v-if="loading"></u-loading-icon>
			<view v-if="datalist">
				<view class="jiaonliguanli" v-for="(item,index) in datalist" :key="index">
					<view class="view-layout" v-if="item.ResumeInfo" @click="JobDetails(item)">
						<view class="view-left">
							<view class="avatars">
								<u-avatar class="avatar-img" :size="54" shape="circle"
									:src="URL+item.ResumeInfo.Avatar">
								</u-avatar>

								<u--image class="avatar-sex"
									:src="item.ResumeInfo.Sex == 1 ? '/static/image/my/man.png' : '/static/image/my/woman.png'"
									width="32rpx" height="32rpx"></u--image>
							</view>
							<view class="tips">
								<span>{{item.ResumeInfo.Age + '岁 '}}</span>
								<span </view>
							</view>
							<view class="view-right">
								<view class="view-right-top">
									<view class="view-right-top-left">
										<span class="name">{{item.ResumeInfo.Name || item.UserName}}</span>
										<view class="tipss">
											<span v-if="item.ResumeInfo.CurrentRole == 0">职场人</span>
											<span v-if="item.ResumeInfo.CurrentRole == 1">学生</span>
										</view>
									</view>
									<view>
										<span v-if="item.ResumeInfo.JobExpect.Negotiable" class="money">可面议</span>
										<span v-else
											class="money">{{numberFormat(item.ResumeInfo.JobExpect.MinWage,true)}}~{{numberFormat(item.ResumeInfo.JobExpect.MaxWage)}}</span>

									</view>
								</view>
								<view class="view-info">
									<span
										v-if="item.ResumeInfo.EducationLevelStr">{{ item.ResumeInfo.EducationLevelStr + ' '}}</span>
									<view class="xian" v-if="item.ResumeInfo.EducationLevelStr"></view>
									<span>{{ (item.ResumeInfo.WorkYear == -1?'在校生':item.ResumeInfo.WorkYear == 0?'应届生':item.ResumeInfo.WorkYear+'年经验')+ ' '}}</span>
									<view class="xian" v-if="item.ResumeInfo.WorkYear"></view>
									<span>{{item.ResumeInfo.JobExpect.WorkTypeStr+ ' '}}</span>
									<view class="xian" v-if="item.ResumeInfo.JobExpect.WorkTypeStr"></view>
									<span>{{item.ResumeInfo.CurrentStatusStr+ ' '}}</span>
								</view>
								<view class="view-info flexasd">
									<view class="view-info-text">
										期望职位：{{item.ResumeInfo.JobExpect.PositionName || item.ResumeInfo.JobExpect.CustomPositionName}}
									</view>
									<!-- <view class="view-info-text">期望城市：{{item.ResumeInfo.JobExpect.PcaAddress}}
								</view> -->
								</view>

							</view>
						</view>
					</view>
					<u-loadmore :status="status" />

				</view>
				<u-empty v-else mode="data" icon="/static/recruit/index/qsy.png" width="350" marginTop="150">
				</u-empty>
		</scroll-view>
	</view>

</template>
<script>
	import baseHead from '@/pages/component/baseHead.vue'
	export default {
		filters: {
			userNums(num) {
				return num < 10000 ? num : (num / 1000).toFixed(1) + 'k'
			}
		},
		data() {
			return {
				statusBarH: 0, //状态栏高度
				customBarH: 0, //导航栏高度
				windowHeight: 0, //窗口高度
				safeAreaInsets: 0,
				URL: this.$config.domain.staticUrl,
				checkedAll: [],
				value: [{
					name: '全选',
					disabled: false
				}],

				checked: 0,
				keyword: '请输入',

				datalist: [],

				obj: {
					KeyWord: '',
					PageIndex: 1,
					PageSize: 10
				},
				status: 'loadmore',
				loading:false, //控制刷新图标显示
				Id:'',
			}
		},

		//子组件
		components: {
			baseHead
		},
		onLoad(e) {
			this.Id = e.Id
		},
		created() {
			const app = getApp()
			// 获取状态栏和导航条高度 窗口宽度
			this.statusBarH = app.globalData.statusBarH;
			this.customBarH = app.globalData.customBarH;
			this.windowHeight = app.globalData.phoneInformation.windowHeight;
			this.safeAreaInsets = app.globalData.phoneInformation.safeAreaInsets.bottom;
			this.listdata()
		},
		// 下拉刷新
		onPullDownRefresh() {
			this.obj = {
				PageIndex: 1,
				PageSize: 10,
				KeyWord: ''
			}
			this.listdata()
			uni.stopPullDownRefresh(); //停止刷新
		},

		// onReachBottom() {

		// 	console.log("懒加载")
		// 	// 加载前值为loadmore，加载中为loading，没有数据为nomore
		// 	if (this.status != "nomore") {
		// 		this.status = "loading";
		// 		this.listdata()
		// 	}
		// },

		// 计算方法
		methods: {
			
			//列表上拉刷新
			onrefresh(){
				this.loading = true
				setTimeout(() => {
					this.loading = false;
					this.datalist = [];
					this.listdata();
				}, 1000);
			},
			
			// 列表懒加载
			lower() {
				if (this.status != "nomore") {
					this.listdata();
				} else {
					$util.toast("没有更多数据了");
				}
			},

			numberFormat(num, val) {
				let newNum = num / 1000
				newNum = newNum.toString()
				const index = newNum.indexOf('.')
				if (index !== -1) {
					if (!val) {
						return parseFloat(newNum).toFixed(1) + 'k'
					} else {
						return parseFloat(newNum).toFixed(1)
					}
				} else {
					if (!val) {
						return parseFloat(newNum) + 'k'
					} else {
						return parseFloat(newNum)
					}
				}
			},


			// 跳转详情
			JobDetails(item) {
				console.log(item);
				let int = item.ResumeInfo.JobExpectId;
				uni.navigateTo({
					url: `/pages/views/packageA/type-recruit/search/JobDetails?key=${int}`,
				});
			},


			listdata(val) {
				let obj = {
					PageIndex: this.obj.PageIndex,
					PageSize: this.obj.PageSize,
					HasChat: 1,
				}
				if(this.Id == undefined){
					obj.JobId = null
				}else{
					obj.JobId = this.Id
				}
				this.$http.huirc.jobUserRecordlist(obj).then(res => {
					if (res.Result) {
						// console.log(uni.getStorageSync('dianjiqiye'))
						if (this.obj.PageIndex == 1 && res.Result.Items.length == 0) {
							this.datalist = [];
						} else {
							if (res.Result.Items.length == 0) {
								// 没有数据----
								this.status = "nomore";
								return;
							}
							this.datalist = this.datalist.concat(res.Result.Items).map(item => {
								return {
									...item,
									checked: false
								}
							});
						}

						if (res.Result.Items.length >= this.obj.PageSize) {
							this.obj.PageIndex++;
							// 表示还有数据
						} else {
							//没有更多数据了
							this.status = "nomore";
						}
					}
				})
			},

		}
	}
</script>

<style lang="scss" scoped>
	.jiaonliguanli {
		background-color: #ffffff;
		margin: 20rpx;
		box-sizing: border-box;
		padding: 0 20rpx;
		box-sizing: border-box;
		overflow: hidden;
		border-radius: 20rpx;

		.view-layout {
			display: flex;
			justify-content: space-between;
			padding: 30rpx 0;
			box-sizing: border-box;

			.view-left {

				.avatars {
					position: relative;
					display: flex;
					width: 108rpx;
					height: 108rpx;
					box-sizing: border-box;

					.avatar-img {
						position: absolute;
					}

					.avatar-sex {
						position: absolute;
						right: 0;
						bottom: 0;

						span {
							background-color: #fff;
							color: #fff;
						}
					}
				}

				.tips {
					margin-top: 20rpx;
					text-align: center;
					padding: 0 10rpx;
					font-size: 24rpx;
					font-weight: 400;
					color: #000000;

				}

			}

			.view-right {
				margin-left: 25rpx;
				flex: 1;
				box-sizing: border-box;

				.view-right-top {
					width: 100%;
					display: flex;
					justify-content: space-between;
					box-sizing: border-box;
					margin-top: 10rpx;

					.view-right-top-left {
						display: flex;

						.name {
							color: #000000;
							font-weight: 500;
							margin-right: 10rpx;
							font-size: 36rpx;
						}

						.tipss {
							padding: 5rpx 17rpx;
							border-radius: 10rpx;
							opacity: 1;
							border: 1rpx solid #476DF0;
							font-size: 24rpx;
							font-weight: 400;
							color: #476DF0;
							display: flex;
							justify-content: center;
							align-items: center;

						}



					}


					.money {
						margin-left: 20rpx;
						font-size: 34rpx;
						font-weight: 400;
						color: #F35370;
					}



				}

				.view-info {
					margin-top: 20rpx;
					display: flex;
					align-items: center;

					span {
						font-size: 24rpx;
						color: #313131;
						line-height: 24rpx;

						&:first-child {
							padding-left: 0;
						}

						&:last-child {
							border-right: 0;
						}
					}

					.xian {
						width: 0rpx;
						height: 16rpx;
						opacity: 0.2;
						border: 1rpx solid #707070;
						margin: 0 12rpx;
					}

					.view-info-text {
						// width: 40%;
						font-size: 24rpx;
						color: #313131;
						word-break: keep-all;
						white-space: nowrap;
						overflow: hidden;
						text-overflow: ellipsis;
						margin-top: 4rpx;
					}

				}

				.flexasd {
					display: flex;
					justify-content: start;
				}

			}
		}

	}
</style>